/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 */
package com.apache.order.service.plugins;

import java.util.List;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.cache.util.Validator;
import com.apache.order.entity.OrderMainVo;
import com.apache.order.entity.TOrder;
import com.apache.order.entity.TOrderDetail;
import com.apache.order.manager.TOrderDetailManager;
import com.apache.order.manager.TOrderManager;

/**
 * description:  订单详情
 * @author Hou Dayu 创建时间：2015-8-3  
 * 
 */
public class OrderDetailPluginImpl implements PluginConnector {

	private TOrderManager tOrderManager;
	private TOrderDetailManager tOrderDetailManager;

	/**
	 * TODO 订单详情.  
	 * @see com.dwusoft.api.manager.PluginConnector#execute(com.dwusoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo vo) throws Exception {
		ResultEntity entity = new ResultEntity();
		String orderId = String.valueOf(vo.getParams("orderId"));
		ParamsVo pvo = new ParamsVo();
		pvo.setInfoId(orderId);
		TOrder main = (TOrder) tOrderManager.getInfoById(pvo);
		OrderMainVo order = new OrderMainVo();
		order.fatherToChild(main, order);
		if (!Validator.isEmpty(order)) {
			TOrderDetail product = new TOrderDetail();
			product.setOrderId(orderId);
			pvo.setObj(product);
			List<TOrderDetail> list = tOrderDetailManager.getList(pvo);
			order.setPorducts(list);
		}
		entity.setEntity(order);
		entity.setResult("true");
		entity.setMessage("查询订单[" + orderId + "]成功");
		return entity;
	}

	public void settOrderManager(TOrderManager tOrderManager) {
		this.tOrderManager = tOrderManager;
	}

	public void settOrderDetailManager(TOrderDetailManager tOrderDetailManager) {
		this.tOrderDetailManager = tOrderDetailManager;
	}
}
